<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>汽车信息推送系统</title>

    <script src="__STATIC__/jquery-2.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
    <script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.js"></script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

    {include file="public/header" /}
    {include file="public/left" /}
    <style>
        .layui-table-cell{
            height: 33px;
        }
    </style>



    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <fieldset class="layui-elem-field layui-field-title"  style="margin-top: 50px;">
                <legend>编辑新闻</legend>
            </fieldset>
            <form class="layui-form layui-form-pane" action="{:url('news/modify')}" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">新闻标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="ll_title" value="{$nd.ll_title}"   placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">新闻编号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="ll_aid" value="{$nd.ll_aid}" disabled class="layui-input">
                        <input type="hidden" name="ll_aid" value="{$nd.ll_aid}"  class="layui-input">
                    </div>
                </div>



                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">发布日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="ll_time" value="{$nd.ll_time|date='Y-m-d H:i:s',###}" id="date1" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                </div>
                <div class="layui-form-item">


                    <div class="layui-inline">
                        <label class="layui-form-label">新闻类型</label>
                        <div class="layui-input-inline">
                            <!--<input type="text" name="ll_cid"  value="{$nd.ll_cid}" class="layui-input">-->
                            <select name="ll_cid"  >
                                <option value=""></option>
                                {volist name="catnottree" id="cat"}
                                <option value="{$cat.ll_cid}" {if condition="$cat['ll_cid'] eq $nd['ll_cid']"} selected  {/if} >{for start="1" end="$cat.floor"}----{/for}{$cat.ll_catname}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">

                    {if condition="$nd.ll_url eq NULL "}
                    <div class="layui-inline">
                        <label class="layui-form-label">发布人</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ll_username" disabled value="{$nd.ll_username}"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">发布人id</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ll_uid"  value="{$nd.ll_uid}" class="layui-input">
                        </div>
                    </div>
                    {else /}
                    <div class="layui-inline">
                        <label class="layui-form-label">来源</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ll_username" disabled value="外网"  class="layui-input">
                        </div>
                    </div>

                    {/if}
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label class="layui-form-label">浏览数</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ll_rnum"  value="{$nd.ll_rnum}" class="layui-input">
                        </div>
                    </div>

                </div>






                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">是否发布</label>
                    <div class="layui-input-block">
                        <input type="checkbox" {if condition="$nd['ll_state'] eq 1"}  checked {/if} name="ll_state" lay-skin="switch" lay-filter="switchTest" title="是否发布">

                    </div>
                </div>



                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="upimgbtn">上传图片</button>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="upimg"  src="{if condition="$nd.ll_url eq NULL "}__U__/{$nd.ll_pics}{else /}{$nd.ll_pics}{/if}">
                        <input type="hidden" name="ll_pics" value="{$nd.ll_pics}" id="ll_pics">
                        <p id="demoText"></p>
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">发布内容</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" style="height: 300px" class="layui-textarea" name="ll_content" id="ll_content">{$nd.ll_content}</textarea>
                        <script type="text/javascript">
                            UEDITOR_CONFIG.UEDITOR_HOME_URL = '__STATIC__/ueditor/'; //一定要用这句话，否则你需要去ueditor.config.js修改路径的配置信息
                            UE.getEditor('ll_content',{
                                initialFrameWidth : '98%',
//                            initialFrameHeight: '90%'
                            });
                        </script>
                    </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn" lay-submit="" lay-filter="demo2">提交</button>
                </div>
            </form>


        </div>
    </div>


</div>

<script>

    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;

    });
    $('#logout').click(function (e) {
        e.preventDefault();
        layui.use('layer', function(){
            var layer = layui.layer;

            layer.confirm('你真的要退出吗？',['yes','no'],function () {
                location.href="{:url('login/logout')}";
            },function () {
                
            })
        });
    })


</script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
                ,layer = layui.layer
                ,layedit = layui.layedit
                ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#date1'
            ,type: 'datetime'
        });




        //监听指定开关
        form.on('switch(switchTest)', function(data){
            layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });

        });

        //监听提交
        form.on('submit(demo1)', function(data){
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })
            return false;
        });


    });
</script>

<script>
    layui.use('upload', function(){
        var $ = layui.jquery
                ,upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#upimgbtn'
            ,url: "{:url('upload/index')}"
            ,data:{
                'll_aid':'{$nd.ll_aid}'
            }
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#upimg').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
//                res = eval("("+res+")");
                console.log(res);
                if(res.code > 0){
                    return layer.msg('上传失败');
                }else {
                    $('#ll_pics').val(res.data.src);
                }

                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });



    });
</script>


</body>
</html>